package com.lucas.vo;

import java.util.HashMap;
import java.util.Map;

/**
 * @program: spring_cloud_lagou_homework
 * @author: lucasLu
 **/
public class Result extends HashMap<String,Object> {
    private  static final long serialVersionUID= 1L;
    public Result(){
        put("retcode",0);
        put("retmsg","success");
    }
    public static Result error(){
        return error(500,"未知异常");
    }

    public static Result error(int i, String retmsg) {
        Result result = new Result();
        result.put("retcode",i);
        result.put("retmgs",retmsg);
        return result;
    }
    public static Result error(String msg){
        return error(500,msg);
    }

    public static Result ok(String msg){
        Result result = new Result();
        result.put("retcode",200);
        result.put("retmsg",msg);
        return result;
    }

    public static Result ok(Map<String,Object> map){
        Result r = new Result();
        r.putAll(map);
        return r;
    }

    public static Result ok(){
        return new Result();
    }

    @Override
    public Result put(String key, Object value) {
        super.put(key, value);
        return this;
    }
}
